<?php
/* this file will install required additional database table */
// load wordpress defaults, make global variables/functions available 
$this_file = str_replace( '\\', '/', __FILE__ );
$this_file = explode( 'wp-content', $this_file );
$this_file = $this_file[ 0 ];
		
// required for making tables easier
require_once( $this_file . 'wp-admin/install-helper.php' );

global $wpdb;
$responded = '';

$sql_purchases_history = "CREATE TABLE `" . $wpdb->prefix . "purchases_history` (
  `id` int(11) NOT NULL auto_increment,
  `trans_date` datetime NOT NULL,
  `unique_code` varchar(150) NOT NULL,
  `trans_status` varchar(100) NOT NULL,
  `trans_basket` varchar(1500) NOT NULL,
  `user_name` varchar(250) NOT NULL,
  `user_email` varchar(250) NOT NULL,
  `user_phone` varchar(50) NOT NULL,
  `user_address` varchar(250) NOT NULL,
  `user_zip` varchar(50) NOT NULL,
  `user_city` varchar(100) NOT NULL,
  `user_country` varchar(50) NOT NULL,
  `currency` varchar(20) NOT NULL,
  `gross` varchar(20) NOT NULL,
  `discount` varchar(20) NOT NULL,
  `handling` varchar(20) NOT NULL,
  `tax` varchar(20) NOT NULL,
  `flag_shipped` varchar(20) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";

$create_table_purchases_history = maybe_create_table( $wpdb->prefix . 'purchases_history', $sql_purchases_history );

if( $create_table_purchases_history ) $responded .= 'Table "' . $wpdb->prefix . 'purchases_history" successfully installed!<br />';
else $responded .= 'Table "' . $wpdb->prefix . 'purchases_history" NOT installed yet!<br />';

echo $responded;
?>